import 'package:flutter/material.dart';
import 'package:flutter_layout/app.dart';
import 'package:flutter_layout/base/index.dart';
import 'package:flutter_statusbarcolor_ns/flutter_statusbarcolor_ns.dart';
import 'package:get/get.dart';
import 'login_controller.dart';

// ignore: must_be_immutable
class LoginPage extends GetView<LoginController> {
  String? account;
  String? pwd;

  LoginPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    FlutterStatusbarcolor.setStatusBarColor(Colors.yellow);
    FlutterStatusbarcolor.setStatusBarWhiteForeground(false);
    return Scaffold(
      appBar: AppBar(
        centerTitle: true,
        title: const Text("登录"),
        // elevation: 1,
      ),
      body: SizedBox(
        height: MediaQuery.of(context).size.height,
        width: MediaQuery.of(context).size.width,
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: ListView(
            padding: const EdgeInsets.all(10),
            children: [
              const SizedBox(
                height: 50,
              ),
              Image.asset(
                "assets/images/common/video_loading.png",
                width: 100,
                height: 100,
              ),
              const SizedBox(
                height: 20,
              ),
              TextField(
                  decoration: const InputDecoration(hintText: "请输入手机号码"),
                  onChanged: (value) {
                    account = value;
                    showToast(value.toString());
                  }),
              const SizedBox(
                height: 20,
              ),
              TextField(
                  decoration: const InputDecoration(hintText: "请输入密码"),
                  obscureText: true,
                  onChanged: (value) {
                    pwd = value;
                    showToast(value.toString());
                  }),
              const SizedBox(
                height: 20,
              ),
              SizedBox(
                width: MediaQuery.of(context).size.width,
                height: 45,
                child: ElevatedButton(
                    onPressed: () {
                      if (null == account || null == pwd || account!.isEmpty || pwd!.isEmail) {
                        showToast("请输入账号或者密码");
                        return;
                      }
                      App.loginStatus = 1;
                      showToast("登录成功");
                      // Get.find<HomePage>();
                      // Get.offNamed(Routes.home);
                      Get.back();
                    },
                    child: const Text("登录")),
              )
            ],
          ),
        ),
      ),
    );
  }
}
